<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    var $xinyanApiKey = '035vE48L47o51210'; #新颜密钥
    var $fuiouMchntcd = '0003050F2085718'; #富友商户号
    var $fuiouMchntKey = '2ke3zffpct7eee3lm7ugt6gdvv5lajwm'; #富友协议支付密钥
    var $fuiouMchntOutKey = 'f1o0gglw851dquq7q8s0whw8z6t1a9sy';//转账秘钥

    var $fuiouMchntcd_Test = '0002230F0348879'; #富友测试商户号
    var $fuiouMchntKey_Test = 'AV1qH9cr1zNJlcg+RbGYUdF9t4A9n5'; #富友协议支付测试密钥

    var $md5key =  "youhou is best!!!!";
    var $userState = array(
        0       =>      '待机审',
        -1      =>      '机审不通过',
        1       =>      '机审通过',
        //0       =>      '人工待审',
        -2      =>      '人工审核不通过',
        2       =>      '人工审核通过',

    );

    var $userStateText = array(
        0       =>      '待机审',
        -1      =>      '<span style="color: red;">机审不通过</span>',
        1       =>      '<span style="color: green;">机审通过</span>',
        -2      =>      '<span style="color: red;">人工审核不通过</span>',
        2       =>      '<span style="color: green;">人工审核通过</span>',
    );

    var $state = array(
        1       =>      '审核通过',
        2       =>      '已打款',
        3       =>      '已完成',
        0       =>      '审核中',
        -1      =>      '审核不通过',
        -2      =>      '打款失败',
        -3      =>      '扣款失败',
    );

    var $repaymentState = array(
        1       =>      '待催收',
        2       =>      '催收中',
        3       =>      '委外催收',
        4       =>      '催收完成',
        -1      =>      '已放弃（停止自动扣款）',
    );

    var $stateText = array(
        1       =>      '<span style="color: #f86e25;">审核通过</span>',
        2       =>      '<span style="color: #f86e25;">已打款</span>',
        3       =>      '<span style="color: green;">已完成</span>',
        0       =>      '审核中',
        -1      =>      '<span style="color: peru;">审核不通过</span>',
        -2      =>      '<span style="color: peru;">打款失败</span>',
        -3      =>      '<span style="color: red;font-weight: bold;">扣款失败</span>',
    );

    var $repayStateText = array(
        1       =>      '<span style="color: #f86e25;">待催收</span>',
        2       =>      '<span style="color: #f86e25;">催收中</span>',
        3       =>      '<span style="color: green;">委外催收</span>',
        4       =>      '<span style="color: green;">催收完成</span>',
        -1      =>      '<span style="color: red;">已放弃（停止自动扣款）</span>',

    );

    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public static  function pkcs5_pad ($text, $blocksize)
    {
        $pad = $blocksize - (strlen($text) % $blocksize);
        return $text . str_repeat(chr($pad), $pad);
    }

    public static  function pkcs5_unpad($text)
    {
        $pad = ord($text{strlen($text)-1});
        if ($pad > strlen($text))
        {
            return false;
        }
        if (strspn($text, chr($pad), strlen($text) - $pad) != $pad)
        {
            return false;
        }
        return substr($text, 0, -1 * $pad);
    }
}
